import { history } from 'umi';
import { getKeyRouter } from '@/utils';
import { getSourceBidderManageTableColumns, getSourceBidderManageSearchColumns } from '../mconfig/index';
import { SourceBidderManageService } from '../services/ManageService';

export function useSourceBidderManage() {
  const { SourceBidderManageDataSource, requestManage, loading } = SourceBidderManageService();
  /**
   * @operation
   * @description 管理页操作事件
   */
  const operation = {
    onView: (record: Record<string, any>) => {
      history.push({
        pathname: `/sourceBidderController/view/:${getKeyRouter()}${getKeyRouter()}`,
        state: {
          type: 'view',
          title: '查看中标公告',
          needInfo: record,
        },
      });
    },
  };

  const tableProps = {
    columns: getSourceBidderManageTableColumns(operation),
    dataSource: SourceBidderManageDataSource,
    loading: loading,
    pagination: {},
    rowKey: 'id',
    onPageChange: () => {},
  };

  const searchProps = {
    switchList: [],
    onSwitch: () => {},
    searchList: getSourceBidderManageSearchColumns(),
    onSearch: () => {
      requestManage();
    },
    onReset: () => {
      requestManage();
    },
  };

  const actionList = null;

  return {
    operation,
    tableProps,
    searchProps,
    actionList,
  };
}
